import request from '@/utils/request';
import { UserItem } from './data';

export async function list(params?: any) {
  return request(`/AllLinks/user/_query?paging=false`, {
    method: 'GET',
    params: params,
  });
}

export async function listNoPaging(params?: any) {
  return request(`/AllLinks/user/_query/no-paging`, {
    method: 'GET',
    params: params,
  });
}

export async function saveOrUpdate(params: UserItem) {
  return request(`/AllLinks/user/${params.id}/state-change/${params.status}`, {
    method: 'POST',
    data: params,
  });
}

export async function info(id: string) {
  return request(`/AllLinks/user/${id}`, {
    method: 'GET',
  });
}


export async function remove(id: string) {
  return request(`/AllLinks/user/${id}`, {
    method: 'DELETE',
  });
}


//=================================
export async function queryById(id: string) {
  return request(`/hsweb/user/${id}`, {
    method: 'GET',
  });
}


export async function add(params: UserItem) {
  return request(`/hsweb/user`, {
    method: 'POST',
    data: params,
  });
}

export async function update(params: UserItem) {
  return request(`/hsweb/user/${params.id}`, {
    method: 'PUT',
    data: params,
  });
}
//获取角色下拉框
export async function rolelist() {
  return request(`/AllLinks/dimension/_query/no-paging?terms[0].column=typeId$in&terms[0].value=role`, {
    method: 'GET'
  });
}
//用户列表查询（new）
export async function userlist(params?: any) {
  return request(`/AllLinks/user/query_page`, {
    method: 'POST',
    headers:{'Content-Type': 'application/json'},
    data:params
  });
}
//用户添加/编辑保存
export async function save(params: UserItem) {
  return request(`/AllLinks/user/svup_user`, {
    method: 'POST',
    headers:{'Content-Type': 'application/json'},
    data: params,
  });
}
//列表删除
export async function del(id: string) {
  return request(`/AllLinks/user/${id}/del_user`, {
    method: 'POST'
  });
}
//根据id查询编辑数据
export async function getConById(id: string) {
  return request(`/AllLinks/user/${id}/get_user_info`, {
    method: 'POST'
  });
}
// upload excel
export async function upload(file: string) {
  return request(`/AllLinks/user/user_import?fileUrl=`+file, {
    method: 'GET'
  });
}
//获取机构
export async function getOrganization() {
  return request(`/AllLinks/organize/_all`, {
    method: 'GET'
  });
}
